import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_pagewise/flutter_pagewise.dart';
import 'package:loxen/mode/inspiration/inspiration_info_bean.dart';
import 'package:loxen/view/inspiration/inspiration_item_widget.dart';
import 'package:loxen/viewmode/inspiration_list_viewmodel.dart';
import 'package:loxen/widget/empty_widget.dart';
import 'package:loxen/widget/my_subassembly.dart';
import 'package:provider/provider.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

class InspirationList extends StatelessWidget {
  const InspirationList({Key key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Padding(
      padding: EdgeInsets.only(left: 36.w),
      child: RefreshIndicator(
        onRefresh: () async {
          Provider.of<InspirationListViewModel>(context, listen: false).refresh();
        },
        child: PagewiseListView<InspirationInfo>(
          addAutomaticKeepAlives: false,
          loadingBuilder: (_) => MySubassembly.getLoadingItem(),
          noItemsFoundBuilder: (_) => MySubassembly.getNullItem(msg: '没有更多灵感文章'),
          itemBuilder: (_, entity, index) {
            return ItemWidget(
              entity: entity,
            );
          },
          pageLoadController:
              Provider.of<InspirationListViewModel>(context, listen: false).pageController,
        ),
      ),
    );
  }
}
